const robot = (data, state, running, site,err) => {
  // console.log("数组==>", running);
  if (running.length > 20) {
    running = running.slice(0, 15);
  }

  running.unshift(site + Number(data.valu[17].v));

  if (data.valu[10].v == 1) {
    state.start = true;
  } else {
    state.start = false;
  }

  if (state.start == true) {
    state.img = require("../../assets/images/robot01.gif");
    if (data.valu[0].v == 1) {
      state.hint.maintain = `${state.name}启动程序番号反馈给主控PLC  1`;
    }
    if (data.valu[1].v == 1) {
      state.hint.maintain = `${state.name}启动程序番号反馈给主控PLC  2`;
    }
    if (data.valu[2].v == 1) {
      state.hint.maintain = `${state.name}启动程序番号反馈给主控PLC  4`;
    }
    if (data.valu[3].v == 1) {
      state.hint.maintain = `${state.name}启动程序番号反馈给主控PLC  8`;
    }
    if (data.valu[4].v == 1) {
      state.hint.maintain = `${state.name}启动程序番号反馈给主控PLC  16`;
    }
    if (data.valu[5].v == 1) {
      state.hint.instruct = `${state.name}在取料区`;
    }
    if (data.valu[6].v == 1) {
      state.hint.instruct = `${state.name}在冲压机区`;
    }

    {
      if (data.valu[7].v == 1) {
        state.hint.instruct = `${state.name}在放料区`;
      }
    }

    if (data.valu[8].v == 1) {
      state.hint.instruct = `${state.name}在原点`;
    }

    if (data.valu[9].v == 1) {
      state.hint.instruct = `${state.name}在安全区`;
    }

    if (data.valu[11].v == 1) {
      state.hint.status = `${state.name}处于自动状态`;
    } else {
      state.hint.status = "";
    }

    if (data.valu[12].v == 1) {
      state.hint.status = `${state.name}处于手动状态`;
    }

    if (data.valu[13].v == 1) {
      state.hint.status = `${state.name}处于急停状态`;
    }

    if (data.valu[14].v == 1) {
      state.isactive = true;
      state.img = require("../../assets/images/robot01-fault.png");
      err.unshift({
        name:state.name,
        t:new Date()
      })
      console.log("异常了==>",err);
    }
    if (data.valu[15].v == 1) {
      state.hint.signal = `${state.name}在等待信号`;
    }
    {
      if (data.valu[16].v == 1) {
        state.hint.signal = `${state.name}取料完成`;
      }
    }
    {
      if (data.valu[17].v == 1) {
        state.hint.signal = `${state.name}放料完成`;
      }
    }
    if (data.valu[18].v == 1) {
      state.hint.stuff = `${state.name}抓手有料`;
    }

    if (data.valu[19].v == 1) {
      state.hint.stuff = `${state.name}对应的冲床有料`;
    }
  } else {
    state.img = require("../../assets/images/robot01.gif");
  }
  //   console.log("1号机器人传过来的值==>", data);
};

module.exports = {
  robot,
};
